package com.healthy.support.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.healthy.common.log.annotation.Log;
import com.healthy.common.log.enums.BusinessType;
import com.healthy.common.security.annotation.RequiresPermissions;
import com.healthy.support.domain.FeedbackCategories;
import com.healthy.support.service.IFeedbackCategoriesService;
import com.healthy.common.core.web.controller.BaseController;
import com.healthy.common.core.web.domain.AjaxResult;
import com.healthy.common.core.utils.poi.ExcelUtil;
import com.healthy.common.core.web.page.TableDataInfo;

/**
 * 反馈分类Controller
 * 
 * @author 束伟
 * @date 2024-03-29
 */
@RestController
@RequestMapping("/FeedbackCategories")
public class FeedbackCategoriesController extends BaseController
{
    @Autowired
    private IFeedbackCategoriesService feedbackCategoriesService;

    /**
     * 查询反馈分类列表
     */
    @RequiresPermissions("support:FeedbackCategories:list")
    @GetMapping("/list")
    public TableDataInfo list(FeedbackCategories feedbackCategories)
    {
        startPage();
        List<FeedbackCategories> list = feedbackCategoriesService.selectFeedbackCategoriesList(feedbackCategories);
        return getDataTable(list);
    }

    /**
     * 导出反馈分类列表
     */
    @RequiresPermissions("support:FeedbackCategories:export")
    @Log(title = "反馈分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FeedbackCategories feedbackCategories)
    {
        List<FeedbackCategories> list = feedbackCategoriesService.selectFeedbackCategoriesList(feedbackCategories);
        ExcelUtil<FeedbackCategories> util = new ExcelUtil<FeedbackCategories>(FeedbackCategories.class);
        util.exportExcel(response, list, "反馈分类数据");
    }

    /**
     * 获取反馈分类详细信息
     */
    @RequiresPermissions("support:FeedbackCategories:query")
    @GetMapping(value = "/{categoryId}")
    public AjaxResult getInfo(@PathVariable("categoryId") Long categoryId)
    {
        return success(feedbackCategoriesService.selectFeedbackCategoriesByCategoryId(categoryId));
    }

    /**
     * 新增反馈分类
     */
    @RequiresPermissions("support:FeedbackCategories:add")
    @Log(title = "反馈分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FeedbackCategories feedbackCategories)
    {
        return toAjax(feedbackCategoriesService.insertFeedbackCategories(feedbackCategories));
    }

    /**
     * 修改反馈分类
     */
    @RequiresPermissions("support:FeedbackCategories:edit")
    @Log(title = "反馈分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FeedbackCategories feedbackCategories)
    {
        return toAjax(feedbackCategoriesService.updateFeedbackCategories(feedbackCategories));
    }

    /**
     * 删除反馈分类
     */
    @RequiresPermissions("support:FeedbackCategories:remove")
    @Log(title = "反馈分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{categoryIds}")
    public AjaxResult remove(@PathVariable Long[] categoryIds)
    {
        return toAjax(feedbackCategoriesService.deleteFeedbackCategoriesByCategoryIds(categoryIds));
    }
}
